<!DOCTYPE html>
<html >
<head lang="en">

    <#include "../head_import.html" />

</head>
<body>
<#include "../include/top_nav.html" />
<div class="am-cf admin-main">

    <!-- sidebar start -->
    <#include "../category/left.html">
        <!-- sidebar end -->
        <!-- content start-->
        <div class="admin-content">
            <div class="am-cf am-padding">
                <div class="am-fl am-cf"><@s.m "global.position"/>: <@s.m "category.function"/> - <@s.m "global.list"/></div>
            </div>
            <div class="am-g">
                <div class="am-u-sm-12 am-u-sm-centered">
                    <form class="ropt">
                        <input type="hidden" name="root" value="${root!}"/>
                        <select name="typeId" onchange="if(this.options[this.selectedIndex].value!=''){this.form.action='add.do';this.form.submit();}">
                            <option>--添加子类型--</option>
                            <#list typeList as type>
                                <option value="${type.id}">${type.name}</option>
                            </#list>
                        </select>
                    </form>

                </div>
            </div>
            <div class="am-g">
                <div class="am-u-sm-12 am-u-sm-centered">
                    <form id="tableForm" method="post">
                        <input type="hidden" name="root" value="${root!}"/>
                        <input type="hidden" name="pageNo" value="${pageNo!}"/>
                        <@p.table value=list;category,i,has_next><#rt/>
                        <@p.column title="<input type='checkbox' onclick='Pn.checkbox(\"ids\",this.checked)'/>" width="20">
                        <input type='checkbox' name='ids' value='${category.id}'/><#t/>
                    </@p.column><#t/>
                    <@p.column title="ID" width="20">${category.id!}</@p.column><#t/>
                <@p.column code="category.name"><a href="edit.do?id=${category.id}&pageNo=${pageNo!}">${category.name}</a><input type="hidden" name="wid" value="${category.id}"/></@p.column><#t/>
            <@p.column code="category.path">${category.path}<input type="hidden" name="wids" value="${category.id}"/></@p.column><#t/>
        <@p.column code="category.type">${category.type.name}</@p.column><#t/>
                    <@p.column code="global.priority" align="center"><input type="text" name="priority" value="${category.priority}" style="width:30px"/></@p.column><#t/>
                <@p.column code="global.operate" align="center">
                <!--  <a href="add.do?root=${category.id}"><@s.m "category.addSub"/></a> | <#rt/>-->
                <a href="edit.do?id=${category.id}&root=${root!}"><@s.m "global.edit"/></a> | <#rt/>
                <a href="o_delete.do?ids=${category.id}&root=${root!}" onclick="if(!confirm('<@s.m "global.confirm.delete"/>')) {return false;}"><@s.m "global.delete"/></a><#t/>
                </@p.column><#t/>
                </@p.table>
                    <div>
                        <input type="button" value="<@s.m "global.delete"/>" onclick="optDelete();"/>
                        &nbsp; <input type="button" value="<@s.m "global.saveOrder"/>" onclick="optSaveOrder();"/>
                    </div>
                    </form>

          </div>
</div>
<!-- content end-->
</div>

</div>

<#include "/common/alert_message.html"/>


<script type="text/javascript">
    function getTableForm() {
        return document.getElementById('tableForm');
    }
    function optDelete() {
        if(Pn.checkedCount('ids')<=0) {
            alert("<@s.m 'error.checkRecord'/>");
            return;
        }
        if(!confirm("<@s.m 'global.confirm.delete'/>")) {
            return;
        }
        var f = getTableForm();
        f.action="o_delete.do";
        f.submit();
    }
    function optSaveOrder() {
        var f = getTableForm();
        f.action="o_priority.do";
        f.submit();
    }
</script>

</body>
</html>